﻿using System;

namespace HYCodeBase.StringUtility
{
	public sealed class StrCoderFactory
	{
		private StrCoderFactory()
		{
		}

		public static StrCoderFactory GetCoderFactory(bool ifReSet = false)
		{
			if (StrCoderFactory.m_signalTag == null || ifReSet)
			{
				StrCoderFactory.m_signalTag = new StrCoderFactory();
			}
			return StrCoderFactory.m_signalTag;
		}

		public IStrCoder GetCoder(string inputRequest = null)
		{
			if (inputRequest != null && inputRequest.Equals("HY"))
			{
				return new HYBase64Coder();
			}
			return new AesCoder(inputRequest);
		}

		public IEnCoder GetEncoder(string inputRequest = null)
		{
			if (inputRequest != null && inputRequest.Equals("MD5"))
			{
				return new MD5Coder();
			}
			if (inputRequest != null && inputRequest.Equals("HY"))
			{
				return new HYBase64Coder();
			}
			return new AesCoder(inputRequest);
		}

		private static StrCoderFactory m_signalTag;

		public const string m_strMD5 = "MD5";

		public const string m_strHY = "HY";
	}
}
